<<<<<<< .mine
# WARN IF LIBRARIES NOT THERE?
import os,sys
import time

def read(file):
    file=open(file,'r')
    read=file.read()
    file.close()
    return read
class sink:
    name='Computer'
    files=[]
    ext='.'
    def __init__(self,config):
        if config=={}:
            print "No information for Computer"
            config['folder']=raw_input('Folder: ')
            os.environ['SYNC.PC.FOLDER']=config['folder']
        self.config=config
    def getContent(self,file):
        return read(os.path.join(self.config['folder'],file['folder'],file['title']+self.ext+file['format']))
    def get_folder(self,folder):
        files=[]
        for file in os.listdir(os.path.join(self.config['folder'],folder)):
            if os.path.isdir(os.path.join(folder,file)):
                for file in self.get_folder(os.path.join(folder,file)):
                    files.append(file)
            elif os.path.isfile(os.path.join(self.config['folder'],folder,file)):
                try: format=file.split('.')[1]
                except(IndexError): break # ? any other way of getting format ?
                file={'title':file.split('.')[0],
                              'format':format,
                              'folder':folder,
                              'updated':time.strftime("%Y-%m-%dT%H:%M:%S.000Z",time.gmtime(os.path.getmtime(os.path.join(self.config['folder'],folder,file))))}
                if sys.platform=='win32':
                    file.update({'published':time.strftime("%Y-%m-%dT%H:%M:%S.000Z",time.gmtime(os.path.getctime(os.path.getmtime(os.path.join(self.config['folder'],folder,file)))))})
                #if sys.platform=='linux2':
                #    title = file['title']
                #    title=title.replace(' ','\ ')
                #    os.system('ls -l %s' % os.path.join(self.config['folder'],file['folder'],title+self.ext+file['format']))
                #    s=sys.stdout.read()
                #    owner=s.split(' ')[2]
                #    group=s.split(' ')[3]
                #    print owner
                #    print group
                files.append(file)
        return files
    def get_files(self):
        return self.get_folder('.')
    def remove(self,file):
        os.remove(os.path.join(self.config['folder'],file['title']+'.'+file['format']))
    def create(self,file):
        if file['folder']!='' and not os.path.exists(file['folder']):
            os.mkdir(os.path.join(self.config['folder'],file['folder']))
        
        f=open(os.path.join(self.config['folder'],file['folder'],file['title']+'.'+file['format']),'w')
        f.write(file['content'])
        f.close()=======
def read(file):
    file=open(file,'r')
    read=file.read()
    file.close()
    return read
class sink:
    name='Computer'
    files=[]
    ext='.'
    def __init__(self,config):
        # WARN IF LIBRARIES NOT THERE?
        import os,sys
        import time
        
        self.config=config
    def getContent(self,file):
        return read(os.path.join(self.config['folder'],file['folder'],file['title']+self.ext+file['format']))
    def get_folder(self,folder):
        files=[]
        for file in os.listdir(os.path.join(self.config['folder'],folder)):
            if os.path.isdir(os.path.join(folder,file)):
                for file in self.get_folder(os.path.join(folder,file)):
                    files.append(file)
            elif os.path.isfile(os.path.join(self.config['folder'],folder,file)):
                try: format=file.split('.')[1]
                except(IndexError): break # ? any other way of getting format ?
                                
                file={'title':file.split('.')[0],
                              'format':format,
                              'folder':folder
                              #'author':{'name':'','email':''}
                              }
                file.update({'updated': time.strftime("%Y-%m-%dT%H:%M:%S.000Z",time.gmtime(os.path.getmtime(os.path.join(self.config['folder'],file['folder'],file['title']+self.ext+file['format']))))})
                if sys.platform=='win32':
                    file.update({'published':time.strftime("%Y-%m-%dT%H:%M:%S.000Z",time.gmtime(os.path.getctime(os.path.join(self.config['folder'],file['folder'],file['title']+self.ext+file['format']))))})
                files.append(file)
        return files
    def get_files(self):
        return self.get_folder('')
    def remove(self,file):
        os.remove(os.path.join(self.config['folder'],file['title']+'.'+file['format']))
    def create(self,file):
        f=open(os.path.join(self.config['folder'],file['title']+'.'+file['format']),'w')
        f.write(file['content'])
        f.close()>>>>>>> .r14
